//
//  EvaDetailUserInfoCell.m
//  BaseProject
//
//  Created by 王洋 on 2021/3/1.
//  Copyright © 2021 王洋. All rights reserved.
//
#import "ZZStarView.h"

#import "EvaDetailUserInfoCell.h"

@interface EvaDetailUserInfoCell ()

@property (nonatomic, strong) ZZStarView *starView;


@end

@implementation EvaDetailUserInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];

    [self.starBGView addSubview:self.starView];

    [self.starView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];

}

- (void)layoutSubviews {
    [super layoutSubviews];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.userIcon pp_clipCorners:UIRectCornerAllCorners radius:self.userIcon.frame.size.height/2];
    });
}

- (void)fillCellWithModel:(CommonEvaluateModel *)model {
    
    self.starView.grade = model.ueEvaluateStar;

    if (model.ueEvaluateStar > 0) {
        self.starLab.text = [NSString stringWithFormat:@"%.1f分",model.ueEvaluateStar];
    } else {
        self.starLab.text = @"暂无评分";
    }
    
    if (model.imgUrl.length>0) {
        [self.userIcon sd_setImageWithURL:[NSURL URLWithString:model.imgUrl] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    }
    
    self.userName.text = model.nickname;
    self.timeLab.text = model.ueEvaluateTime;
}

- (ZZStarView *)starView {
    
    if (!_starView) {

        _starView = [[ZZStarView alloc] initWithImage:[UIImage imageNamed:@"daxing_nor"] selectImage:[UIImage imageNamed:@"daxing_sel"] starWidth:12 starHeight:12 starMargin:2 starCount:5 callBack:^(CGFloat userGrade, CGFloat finalGrade) {
        }];
        //默认值, 可以不写, 用户可选分值范围是0.5的倍数.(建议在设置分值之前确定此值)
        _starView.sublevel = 0.5;
        //设置分值, 可以不写, 默认显示0分.(self.params是UIViewController在ZZRouter中扩展的属性, 包含了所有参数)
        _starView.grade = 0.0;
        //最小值, 默认0.5可以不写, 用户可以设置的最低分值.
        _starView.miniGrade = 0;
        _starView.frame = CGRectMake(0, 0, 70, 14);

    }
    return _starView;
}

@end
